import * as THREE from "three";
import vertex from "../shader/smoke/vertex.glsl";
import fragment from "../shader/smoke/fragment.glsl";

export default class CoffeeSmoke {
  constructor() {
    this.main = new THREE.Mesh();
    this.material = this.createMaterial();
  }

  createMaterial() {
    return new THREE.ShaderMaterial({
      vertexShader: vertex,
      fragmentShader: fragment,
      transparent: true,
      side: THREE.DoubleSide,
      uniforms: {
        uTime: {
          value: 0
        }
      }
    });
  }

  add(mesh) {
    this.main = mesh;
    this.main.material = this.material;
  }

  update(estimatedTime) {
    this.material.uniforms.uTime.value = estimatedTime;
    this.material.needsUpdate = true;
  }


}